﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for BrandDAL
/// </summary>
public class BrandDAL : BaseDAL
{
    public DataSet List(int pageIndex, int pageMax, int brandId)
    {
        DataSet ds = new DataSet();
        string query = string.Format("select * from Brands");
        ds = base.RunQuery(query);
        return ds;
    }
    public DataSet Detail(int brandId)
    {
        DataSet ds = new DataSet();
        
        string query = string.Format("select * from Brands where BrandId = {0} and IsActive = 1;", brandId.ToString());
        ds = base.RunQuery(query);
        
        return ds;
    }
    public DataSet Insert(string brandName, string logo, int isActive)
    {
        DataSet ds = new DataSet();
        string query = string.Format("insert into brands (BrandName, BrandLogo, isActive) values ('{0}','{1}',{2});Select @@identity as BrandId;", brandName, logo, isActive);
        ds = base.RunQuery(query);
        return ds;
    }
    public DataSet Update(int brandid, string brandName, int isActive, string urlLogo)
    {
        DataSet ds = new DataSet();
        string query = string.Format("update brands set brandName='{0}', IsActive={1}, BrandLogo='{2}' where brandid={3};select {3} as brandid", brandName, isActive.ToString(), urlLogo, brandid);
        ds = base.RunQuery(query);
        return ds;
    }
    public DataSet UpdateStatusActive(int brandid, int isActive)
    {
        DataSet ds = new DataSet();
        string query = string.Format("update brands set IsActive={0} where brandid={1}; select {1} as BrandId;", isActive, brandid);
        ds = base.RunQuery(query);
        return ds;
    }
    public string InsertBrandProduct(int brandId, int productId)
    {
        string ret = "";
        DataSet ds = new DataSet();
        string query = string.Format("insert into brand_products(brandid, productid) value({0},{1});select 1", brandId, productId);
        ds = base.RunQuery(query);
        return ret;
    }
}